package cn.com.dcsgo.feign.fallback;

import cn.com.dcsgo.constant.BusinessEnum;
import cn.com.dcsgo.domain.Prod;
import cn.com.dcsgo.dto.SkuDTO;
import cn.com.dcsgo.dto.StockUpdateDTO;
import cn.com.dcsgo.feign.ProdFeignClient;
import cn.com.dcsgo.model.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

/**
 * ProdFeignClient 兜底回调
 *
 * @author Dcsgo
 * @since 2025/10/28 18:31
 */
@Slf4j
@Component
public class ProdFeignClientFallback implements ProdFeignClient {
    @Override
    public Result<Prod> getBasicProdInfo(Long prodId) {
        return Result.fail(BusinessEnum.SERVER_INNER_ERROR);
    }

    @Override
    public List<Prod> getBasicProdInfoByIds(Set<Long> prodIds) {
        log.error("RPC错误：商品的远程调用走了兜底回调");
        return new ArrayList<>(0);
    }

    @Override
    public List<SkuDTO> getSkuDTOListBySkuIds(Set<Long> skuIds) {
        log.error("RPC错误：商品的远程调用 getSkuDTOListBySkuIds 走了兜底回调");
        return new ArrayList<>(0);
    }

    @Override
    public boolean updateStock(StockUpdateDTO stockUpdateDTO) {
        log.error("RPC错误：商品的远程调用 updateStock 走了兜底回调");
        return false;
    }
}
